
 <!DOCTYPE HTML>
<html >
<head>
  <meta charset="UTF-8">
  
    <title>编写链码程序并测试 | B3434lockchain</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=no">
    
    <meta name="author" content="b3434lockchain">
    

    
    <meta name="description" content="1.链码编写这里编写的是一个关于投票的链码程序，因为之前那个比较多错误，所以这里就重新编写了一个投票链码。 这里除了实现Init和Invoke方法以外，还实现了四个方法：create()，vote()，query()和remove().其功能分别对应创建候选人、投票、查询候选人票数以及删除候选人。 package main  import (     &amp;quot;fmt&amp;quot;     &amp;qu">
<meta name="keywords" content="周报,卢家豪">
<meta property="og:type" content="article">
<meta property="og:title" content="编写链码程序并测试">
<meta property="og:url" content="http://b3434lockchain.gitee.io/2018/11/25/lujiahao/lujiahao5/index.html">
<meta property="og:site_name" content="B3434lockchain">
<meta property="og:description" content="1.链码编写这里编写的是一个关于投票的链码程序，因为之前那个比较多错误，所以这里就重新编写了一个投票链码。 这里除了实现Init和Invoke方法以外，还实现了四个方法：create()，vote()，query()和remove().其功能分别对应创建候选人、投票、查询候选人票数以及删除候选人。 package main  import (     &amp;quot;fmt&amp;quot;     &amp;qu">
<meta property="og:locale" content="default">
<meta property="og:image" content="https://i.imgur.com/5zonjKx.png">
<meta property="og:image" content="https://i.imgur.com/t06TuVY.png">
<meta property="og:image" content="https://i.imgur.com/9EpwXV4.png">
<meta property="og:image" content="https://i.imgur.com/o1D4Eb7.png">
<meta property="og:image" content="https://i.imgur.com/b7iDP9w.png">
<meta property="og:image" content="https://i.imgur.com/AItFD90.png">
<meta property="og:image" content="https://i.imgur.com/JSCGbVj.png">
<meta property="og:image" content="https://i.imgur.com/xOYcjgD.png">
<meta property="og:image" content="https://i.imgur.com/FqLs3Kt.png">
<meta property="og:image" content="https://i.imgur.com/EvhxRd5.png">
<meta property="og:image" content="https://i.imgur.com/9l7KoYe.png">
<meta property="og:image" content="https://i.imgur.com/sA7grK2.png">
<meta property="og:image" content="https://i.imgur.com/reO4kJc.png">
<meta property="og:image" content="https://i.imgur.com/Mskb6Oc.png">
<meta property="og:image" content="https://i.imgur.com/vN8XdFH.png">
<meta property="og:image" content="https://i.imgur.com/zqamlyR.png">
<meta property="og:image" content="https://i.imgur.com/xxii1J5.png">
<meta property="og:image" content="https://i.imgur.com/lAGUJPk.png">
<meta property="og:image" content="https://i.imgur.com/BDW5kk5.png">
<meta property="og:image" content="https://i.imgur.com/EUw1IVp.png">
<meta property="og:updated_time" content="2018-11-26T11:11:26.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="编写链码程序并测试">
<meta name="twitter:description" content="1.链码编写这里编写的是一个关于投票的链码程序，因为之前那个比较多错误，所以这里就重新编写了一个投票链码。 这里除了实现Init和Invoke方法以外，还实现了四个方法：create()，vote()，query()和remove().其功能分别对应创建候选人、投票、查询候选人票数以及删除候选人。 package main  import (     &amp;quot;fmt&amp;quot;     &amp;qu">
<meta name="twitter:image" content="https://i.imgur.com/5zonjKx.png">

    
    <link rel="alternative" href="/atom.xml" title="B3434lockchain" type="application/atom+xml">
    
    
    <link rel="icon" href="/img/favicon.ico">
    
    
    <link rel="apple-touch-icon" href="/img/jacman.jpg">
    <link rel="apple-touch-icon-precomposed" href="/img/jacman.jpg">
    
    <link rel="stylesheet" href="/css/style.css">
</head>

  <body>
    <header>
      
<div>
		
			<div id="imglogo">
				<a href="/"><img src="/img/logo.png" alt="B3434lockchain" title="B3434lockchain"/></a>
			</div>
			
			<div id="textlogo">
				<h1 class="site-name"><a href="/" title="B3434lockchain">B3434lockchain</a></h1>
				<h2 class="blog-motto"></h2>
			</div>
			<div class="navbar"><a class="navbutton navmobile" href="#" title="Menu">
			</a></div>
			<nav class="animated">
				<ul>
					<ul>
					 
						<li><a href="/">Home</a></li>
					
						<li><a href="/archives">Archives</a></li>
					
						<li><a href="/about">About</a></li>
					
					<li>
 					
						<form class="search" action="https://www.baidu.com" target="_blank">
							<label>Search</label>
						<input name="s" type="hidden" value=  ><input type="text" name="q" size="30" placeholder="Search"><br>
						</form>
					
					</li>
				</ul>
			</nav>			
</div>
    </header>
    <div id="container">
      <div id="main" class="post" itemscope itemprop="blogPost">
  
	<article itemprop="articleBody"> 
		<header class="article-info clearfix">
  <h1 itemprop="name">
    
      <a href="/2018/11/25/lujiahao/lujiahao5/" title="编写链码程序并测试" itemprop="url">编写链码程序并测试</a>
  </h1>
  <p class="article-author">By
       
		<a href="/about" title="b3434lockchain" target="_blank" itemprop="author">b3434lockchain</a>
		
  <p class="article-time">
    <time datetime="2018-11-25T15:00:00.000Z" itemprop="datePublished"> Published 2018-11-25</time>
    
  </p>
</header>
	<div class="article-content">
		
		<div id="toc" class="toc-article">
			<strong class="toc-title">Contents</strong>
		
			<ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#1-链码编写"><span class="toc-number">1.</span> <span class="toc-text">1.链码编写</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#2-开发者模式进行链码测试"><span class="toc-number">2.</span> <span class="toc-text">2.开发者模式进行链码测试</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#2-1-终端一"><span class="toc-number">2.1.</span> <span class="toc-text">2.1.终端一</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-2-终端二"><span class="toc-number">2.2.</span> <span class="toc-text">2.2.终端二</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-3-终端三"><span class="toc-number">2.3.</span> <span class="toc-text">2.3.终端三</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#3-first-network上进行链码测试"><span class="toc-number">3.</span> <span class="toc-text">3.first-network上进行链码测试</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#总结"><span class="toc-number">4.</span> <span class="toc-text">总结</span></a></li></ol>
		
		</div>
		
		<h1 id="1-链码编写"><a href="#1-链码编写" class="headerlink" title="1.链码编写"></a>1.链码编写</h1><p>这里编写的是一个关于投票的链码程序，因为之前那个比较多错误，所以这里就重新编写了一个投票链码。</p>
<p>这里除了实现Init和Invoke方法以外，还实现了四个方法：create()，vote()，query()和remove().其功能分别对应创建候选人、投票、查询候选人票数以及删除候选人。</p>
<pre><code>package main

import (
    &quot;fmt&quot;
    &quot;encoding/json&quot;
    &quot;github.com/hyperledger/fabric/core/chaincode/shim&quot;
    &quot;github.com/hyperledger/fabric/protos/peer&quot;
)

type MySimpleChaincode struct {

}

type candidate struct{
    VoteName string `json:&quot;voteName&quot;`
    VoteNum int `json:&quot;voteNum&quot;`
}

func (t *MySimpleChaincode) Init(stub shim.ChaincodeStubInterface) peer.Response {

    fmt.Println(&quot;MySimpleChaincode -&gt; Init&quot;)
    return shim.Success(nil)
}

func (t *MySimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) peer.Response {

    fmt.Println(&quot;MySimpleChaincode -&gt; Invoke&quot;)

    function, args := stub.GetFunctionAndParameters()
    if function == &quot;create&quot; {
        return t.create(stub, args)
    } else if function == &quot;vote&quot; {
        return t.vote(stub, args)
    } else if function == &quot;query&quot; {
        return t.query(stub, args)
    } else if function == &quot;remove&quot; {
    return t.remove(stub, args)
    }

    return shim.Error(&quot;function name is error&quot;)
}

func (t *MySimpleChaincode) create(stub shim.ChaincodeStubInterface, args []string) peer.Response{

    if len(args) == 0 {
        return shim.Error(&quot;args can&apos;t be null&quot;)
    }
    voteName := args[0]
    //判断voteName是否存在
    voteAsBytes, err := stub.GetState(voteName)
    if err != nil {
        return shim.Error(err.Error())
    }
    if voteAsBytes != nil {
        return shim.Error(&quot;cnadidate had already exist&quot;)
    }
    voteNum := 1
    //candidate := &amp;candidate(voteName,voteNum)
    candidate := candidate{VoteName: voteName, VoteNum: voteNum}
    candidateJsonAsBytes, err := json.Marshal(candidate)
    err = stub.PutState(voteName,candidateJsonAsBytes)
    if err != nil {
        return shim.Error(err.Error())
    }
    return shim.Success(nil)
}

func (t *MySimpleChaincode) vote(stub shim.ChaincodeStubInterface, args []string) peer.Response {

    if len(args) == 0 {
        return shim.Error(&quot;args can&apos;t be null&quot;)
    }
    voteName := args[0]
    candidateAsBytes , err := stub.GetState(voteName)
    if err != nil {
        return shim.Error(err.Error())
    } else if  candidateAsBytes == nil {
        return shim.Error(&quot;candidate is not exist&quot;)
    }
    candidate := candidate{}
    err = json.Unmarshal(candidateAsBytes , &amp;candidate)
    if err != nil {
        return shim.Error(err.Error())
    }
    candidate.VoteNum += 1
    candidateJsonAsBytes, err := json.Marshal(candidate)
    if err != nil {
        return shim.Error(err.Error())
    }
    err = stub.PutState(voteName, candidateJsonAsBytes)
    if err != nil {
        return shim.Error(err.Error())
    }
    return shim.Success(nil)
}

func (t *MySimpleChaincode) query(stub shim.ChaincodeStubInterface, args []string) peer.Response {
    if len(args) == 0 {
        return shim.Error(&quot;args can&apos;t be null&quot;)
    }
    voteName := args[0]
    candidateAsBytes , err := stub.GetState(voteName)
    if err != nil {
        return shim.Error(err.Error())
    } else if  candidateAsBytes == nil {
        return shim.Error(&quot;candidate is not exist&quot;)
    }
    return shim.Success(candidateAsBytes)
}

func (t *MySimpleChaincode) remove(stub shim.ChaincodeStubInterface, args []string) peer.Response {
    if len(args) == 0 {
        return shim.Error(&quot;args can&apos;t be null&quot;)
    }
    voteName := args[0]
    err := stub.DelState(voteName)
    if err != nil {
        return shim.Error(err.Error())
    } 
    return shim.Success(nil)
}

func main() {
    err := shim.Start(new(MySimpleChaincode))
    if err != nil {
        fmt.Printf(&quot;start chaincode error&quot;)
    }
}
</code></pre><h1 id="2-开发者模式进行链码测试"><a href="#2-开发者模式进行链码测试" class="headerlink" title="2.开发者模式进行链码测试"></a>2.开发者模式进行链码测试</h1><p>在开发者模式下进行测试，需要开启三个终端，都进入到fabric-samples下的chaincode-docker-devmode目录下。同时需要将所要测试的代码放入hyperledger-fabric/fabric-samples/chaincode目录下。</p>
<h2 id="2-1-终端一"><a href="#2-1-终端一" class="headerlink" title="2.1.终端一"></a>2.1.终端一</h2><p>首先执行一下两行命令，将后台还在运行的容器停止并且删除。</p>
<pre><code>$ docker stop $(docker ps -a -q)
$ docker rm $(docker ps -a -q)
</code></pre><p>接下来使用如下命令来启动网络。</p>
<pre><code>$ docker-compose -f docker-compose-simple.yaml up
</code></pre><p>其运行结果如下图显示。</p>
<p><img src="https://i.imgur.com/5zonjKx.png" alt=""><br><img src="https://i.imgur.com/t06TuVY.png" alt=""></p>
<h2 id="2-2-终端二"><a href="#2-2-终端二" class="headerlink" title="2.2.终端二"></a>2.2.终端二</h2><p>终端二的作用主要是用来在cli容器中编译并且运行链码。</p>
<pre><code>$ docker exec -it chaincode bash
$ cd sacc
$ go build
$ CORE_PEER_ADDRESS=peer:7052 CORE_CHAINCODE_ID_NAME=mycc:0 ./sacc
</code></pre><p>其运行结果如下图所示。</p>
<p><img src="https://i.imgur.com/9EpwXV4.png" alt=""></p>
<h2 id="2-3-终端三"><a href="#2-3-终端三" class="headerlink" title="2.3.终端三"></a>2.3.终端三</h2><p>终端三的作用是用来测试链码。<br>首先启动cli容器，接着安装链码，然后实例化链码。</p>
<pre><code>$ docker exec -it cli bash
$ peer chaincode install -p chaincodedev/chaincode/myVote -n mycc -v 0
$ peer chaincode instantiate -n mycc -v 0 -c &apos;{&quot;Args&quot;:[&quot;init&quot;,&quot;&quot;]}&apos; -C myc
</code></pre><p>其运行结果如下图所示。</p>
<p><img src="https://i.imgur.com/o1D4Eb7.png" alt=""><br><img src="https://i.imgur.com/b7iDP9w.png" alt=""></p>
<p>接下来就是测试链码的运行与效果显示。</p>
<p>首先是创建候选人。</p>
<pre><code>$ peer chaincode invoke -n mycc -c &apos;{&quot;Args&quot;:[&quot;create&quot;, &quot;test&quot;]}&apos; -C myc
</code></pre><p>其效果如下图所示。</p>
<p><img src="https://i.imgur.com/AItFD90.png" alt=""><br><img src="https://i.imgur.com/JSCGbVj.png" alt=""></p>
<p>接下来是查询候选人的票数。</p>
<pre><code>$ peer chaincode query -n mycc -c &apos;{&quot;Args&quot;:[&quot;query&quot;, &quot;test&quot;]}&apos; -C myc
</code></pre><p>其效果如下图所示。</p>
<p><img src="https://i.imgur.com/xOYcjgD.png" alt=""><br><img src="https://i.imgur.com/FqLs3Kt.png" alt=""></p>
<p>然后是投票功能。</p>
<pre><code>$ peer chaincode invoke -n mycc -c &apos;{&quot;Args&quot;:[&quot;vote&quot;, &quot;test&quot;]}&apos; -C myc
</code></pre><p>其效果如下图所示。</p>
<p><img src="https://i.imgur.com/EvhxRd5.png" alt=""><br><img src="https://i.imgur.com/9l7KoYe.png" alt=""></p>
<p>最后是删除候选人。</p>
<pre><code>$ peer chaincode query -n mycc -c &apos;{&quot;Args&quot;:[&quot;remove&quot;, &quot;test&quot;]}&apos; -C myc
</code></pre><p>其效果如下图所示。</p>
<p><img src="https://i.imgur.com/sA7grK2.png" alt=""><br><img src="https://i.imgur.com/reO4kJc.png" alt=""></p>
<p>至此，投票链码的四个功能已经测试完毕，说明链码的编写以及功能实现都没有问题。</p>
<h1 id="3-first-network上进行链码测试"><a href="#3-first-network上进行链码测试" class="headerlink" title="3.first-network上进行链码测试"></a>3.first-network上进行链码测试</h1><p>接下来在first-network网络上测试编写的链码。因为主要是查看链码是否能成功运行，所以这里就采用脚本来启动网络，而非手动启动网络。</p>
<p>首先执行一下两行命令，将后台还在运行的容器停止并且删除。</p>
<pre><code>$ docker stop $(docker ps -a -q)
$ docker rm $(docker ps -a -q)
</code></pre><p>然后如果不是第一次启动网络，就执行./byfn.sh down命令将网络关闭，不然可能会出现一些问题导致网络启动失败。</p>
<p>接下来就可以来用脚本来启动网络了。</p>
<pre><code>$ ./byfn.sh generate
$ ./byfn.sh up
</code></pre><p>其运行结果如下图所示。</p>
<p><img src="https://i.imgur.com/Mskb6Oc.png" alt=""><br><img src="https://i.imgur.com/vN8XdFH.png" alt=""></p>
<p>在运行cli容器安装链码之前需要进入代码所在目录，并且用如下命令将所要测试的代码文件拷贝到cli容器当中。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ docker cp ./myVote.go cli:/opt/gopath/src/github.com/hyperledger/fabric/peer</span><br></pre></td></tr></table></figure>
<p>然后进入到cli容器当中，用ls命令可以看到myVote.go文件已经在cli容器中。接下来就可以用如下命令安装并实例化链码了。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ peer chaincode install -n myvote -v 1.0 -p github.com/hyperledger/fabric/peer</span><br><span class="line">	$ peer chaincode instantiate -o orderer.example.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n myvote -v 1.0 -c &apos;&#123;&quot;Args&quot;:[&quot;init&quot;,&quot;&quot;,&quot;&quot;]&#125;&apos; -P &apos;OR (&apos;\&apos;&apos;Org1MSP.peer&apos;\&apos;&apos;,&apos;\&apos;&apos;Org2MSP.peer&apos;\&apos;&apos;)&apos;</span><br></pre></td></tr></table></figure>
<p>其效果如下图所示。</p>
<p><img src="https://i.imgur.com/zqamlyR.png" alt=""></p>
<p>然后就可以进行链码的测试了。首先是用如下命令创建候选人。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ peer chaincode invoke -C mychannel -n myvote -c &apos;&#123;&quot;Args&quot;:[&quot;create&quot;,&quot;test&quot;]&#125;&apos; -o orderer.example.com:7050 --tls true –cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem</span><br></pre></td></tr></table></figure>
<p>其效果如下图所示。</p>
<p><img src="https://i.imgur.com/xxii1J5.png" alt=""></p>
<p>接下来可以进行投票。<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ peer chaincode invoke -C mychannel -n myvote -c &apos;&#123;&quot;Args&quot;:[&quot;vote&quot;,&quot;test&quot;]&#125;&apos; -o orderer.example.com:7050 --tls true –cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem</span><br></pre></td></tr></table></figure></p>
<p>其效果如下图所示。</p>
<p><img src="https://i.imgur.com/lAGUJPk.png" alt=""></p>
<p>然后就可以查询候选人票数了。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ peer chaincode query -C mychannel -n myvote -c &apos;&#123;&quot;Args&quot;:[&quot;query&quot;,&quot;test&quot;]&#125;&apos;</span><br></pre></td></tr></table></figure>
<p>其效果如下图所示。</p>
<p><img src="https://i.imgur.com/BDW5kk5.png" alt=""></p>
<p>最后就是删除候选人功能测试。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ peer chaincode invoke -C mychannel -n myvote -c &apos;&#123;&quot;Args&quot;:[&quot;remove&quot;,&quot;me&quot;]&#125;&apos; -o orderer.example.com:7050 --tls true –cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem</span><br></pre></td></tr></table></figure>
<p>其效果如下图所示。</p>
<p><img src="https://i.imgur.com/EUw1IVp.png" alt=""></p>
<p>至此，在first-network网络上测试自己编写的链码程序已经完成了。</p>
<h1 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h1><p>写这个链码程序，其实不算难，之前出错是因为对链码的编写并不熟悉，然后导致了编写程序过程中出现了很多错误。之后我查看了很多链码的示例，对链码程序的编写也有了一定了了解，然后重写这个投票链码就感觉容易多了。但是在测试中还是会有一些错误，比如开启网络前没有清除容器或者上次忘记有./byfn.sh down命令关闭网络，就会出现各种各样的error，但是就没有头绪怎么解决，之后还是找了很多很多资料才发现这个问题。不过也因此印象深刻，知道如何解决这个bug。</p>
  
	</div>
		<footer class="article-footer clearfix">
<div class="article-catetags">


  <div class="article-tags">
  
  <span></span> <a href="/tags/周报/">周报</a><a href="/tags/卢家豪/">卢家豪</a>
  </div>

</div>



	<div class="article-share" id="share">
	
	  <div data-url="http://b3434lockchain.gitee.io/2018/11/25/lujiahao/lujiahao5/" data-title="编写链码程序并测试 | B3434lockchain" data-tsina="" class="share clearfix">
	  </div>
	
	</div>


</footer>

   	       
	</article>
	
<nav class="article-nav clearfix">
 
 <div class="prev" >
 <a href="/2019/04/15/jiaxin/jiaxin1/" title="苏佳鑫第七周周报">
  <strong>上一篇：</strong><br/>
  <span>
  苏佳鑫第七周周报</span>
</a>
</div>


<div class="next">
<a href="/2018/11/24/susijie/susijie5/"  title="第十二周周报">
 <strong>下一篇：</strong><br/> 
 <span>第十二周周报
</span>
</a>
</div>

</nav>

	



</div>  
      <div class="openaside"><a class="navbutton" href="#" title="Show Sidebar"></a></div>

  <div id="toc" class="toc-aside">
  <strong class="toc-title">Contents</strong>
 
 <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#1-链码编写"><span class="toc-number">1.</span> <span class="toc-text">1.链码编写</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#2-开发者模式进行链码测试"><span class="toc-number">2.</span> <span class="toc-text">2.开发者模式进行链码测试</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#2-1-终端一"><span class="toc-number">2.1.</span> <span class="toc-text">2.1.终端一</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-2-终端二"><span class="toc-number">2.2.</span> <span class="toc-text">2.2.终端二</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-3-终端三"><span class="toc-number">2.3.</span> <span class="toc-text">2.3.终端三</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#3-first-network上进行链码测试"><span class="toc-number">3.</span> <span class="toc-text">3.first-network上进行链码测试</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#总结"><span class="toc-number">4.</span> <span class="toc-text">总结</span></a></li></ol>
 
  </div>

<div id="asidepart">
<div class="closeaside"><a class="closebutton" href="#" title="Hide Sidebar"></a></div>
<aside class="clearfix">

  

  
<div class="tagslist">
	<p class="asidetitle">Tags</p>
		<ul class="clearfix">
		
			
				<li><a href="/tags/周报/" title="周报">周报<sup>23</sup></a></li>
			
		
			
				<li><a href="/tags/谭俊熙/" title="谭俊熙">谭俊熙<sup>11</sup></a></li>
			
		
			
				<li><a href="/tags/苏思捷/" title="苏思捷">苏思捷<sup>5</sup></a></li>
			
		
			
				<li><a href="/tags/学习报告/" title="学习报告">学习报告<sup>5</sup></a></li>
			
		
			
				<li><a href="/tags/卢家豪/" title="卢家豪">卢家豪<sup>5</sup></a></li>
			
		
			
				<li><a href="/tags/报告/" title="报告">报告<sup>5</sup></a></li>
			
		
			
				<li><a href="/tags/苏佳鑫/" title="苏佳鑫">苏佳鑫<sup>4</sup></a></li>
			
		
			
				<li><a href="/tags/冯华文/" title="冯华文">冯华文<sup>4</sup></a></li>
			
		
			
				<li><a href="/tags/周报反馈/" title="周报反馈">周报反馈<sup>2</sup></a></li>
			
		
			
				<li><a href="/tags/吴朝捷/" title="吴朝捷">吴朝捷<sup>2</sup></a></li>
			
		
			
				<li><a href="/tags/黎宁/" title="黎宁">黎宁<sup>1</sup></a></li>
			
		
			
				<li><a href="/tags/笔记/" title="笔记">笔记<sup>1</sup></a></li>
			
		
		</ul>
</div>


</aside>
</div>
    </div>
    <footer><div id="footer" >
	
	
	<div class="social-font" class="clearfix">
		
		
		
		
		
		
		
		
		
		
	</div>
			
		

		<p class="copyright">
		
		</p>
</div>
</footer>
    <script src="/js/jquery-2.0.3.min.js"></script>
<script src="/js/jquery.imagesloaded.min.js"></script>
<script src="/js/gallery.js"></script>
<script src="/js/jquery.qrcode-0.12.0.min.js"></script>

<script type="text/javascript">
$(document).ready(function(){ 
  $('.navbar').click(function(){
    $('header nav').toggleClass('shownav');
  });
  var myWidth = 0;
  function getSize(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
  };
  var m = $('#main'),
      a = $('#asidepart'),
      c = $('.closeaside'),
      o = $('.openaside');
  c.click(function(){
    a.addClass('fadeOut').css('display', 'none');
    o.css('display', 'block').addClass('fadeIn');
    m.addClass('moveMain');
  });
  o.click(function(){
    o.css('display', 'none').removeClass('beforeFadeIn');
    a.css('display', 'block').removeClass('fadeOut').addClass('fadeIn');      
    m.removeClass('moveMain');
  });
  $(window).scroll(function(){
    o.css("top",Math.max(80,260-$(this).scrollTop()));
  });
  
  $(window).resize(function(){
    getSize(); 
    if (myWidth >= 1024) {
      $('header nav').removeClass('shownav');
    }else{
      m.removeClass('moveMain');
      a.css('display', 'block').removeClass('fadeOut');
      o.css('display', 'none');
      
      $('#toc.toc-aside').css('display', 'none');
        
    }
  });
});
</script>

<script type="text/javascript">
$(document).ready(function(){ 
  var ai = $('.article-content>iframe'),
      ae = $('.article-content>embed'),
      t  = $('#toc'),
      ta = $('#toc.toc-aside'),
      o  = $('.openaside'),
      c  = $('.closeaside');
  if(ai.length>0){
    ai.wrap('<div class="video-container" />');
  };
  if(ae.length>0){
   ae.wrap('<div class="video-container" />');
  };
  c.click(function(){
    ta.css('display', 'block').addClass('fadeIn');
  });
  o.click(function(){
    ta.css('display', 'none');
  });
  $(window).scroll(function(){
    ta.css("top",Math.max(140,320-$(this).scrollTop()));
  });
});
</script>


<script type="text/javascript">
$(document).ready(function(){ 
  var $this = $('.share'),
      url = $this.attr('data-url'),
      encodedUrl = encodeURIComponent(url),
      title = $this.attr('data-title'),
      tsina = $this.attr('data-tsina'),
      description = $this.attr('description');
  var html = [
  '<div class="hoverqrcode clearfix"></div>',
  '<a class="overlay" id="qrcode"></a>',
  '<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="article-share-facebook" target="_blank" title="Facebook"></a>',
  '<a href="https://twitter.com/intent/tweet?url=' + encodedUrl + '" class="article-share-twitter" target="_blank" title="Twitter"></a>',
  '<a href="#qrcode" class="article-share-qrcode" title="微信"></a>',
  '<a href="http://widget.renren.com/dialog/share?resourceUrl=' + encodedUrl + '&srcUrl=' + encodedUrl + '&title=' + title +'" class="article-share-renren" target="_blank" title="人人"></a>',
  '<a href="http://service.weibo.com/share/share.php?title='+title+'&url='+encodedUrl +'&ralateUid='+ tsina +'&searchPic=true&style=number' +'" class="article-share-weibo" target="_blank" title="微博"></a>',
  '<span title="Share to"></span>'
  ].join('');
  $this.append(html);

  $('.hoverqrcode').hide();

  var myWidth = 0;
  function updatehoverqrcode(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
    var qrsize = myWidth > 1024 ? 200:100;
    var options = {render: 'image', size: qrsize, fill: '#2ca6cb', text: url, radius: 0.5, quiet: 1};
    var p = $('.article-share-qrcode').position();
    $('.hoverqrcode').empty().css('width', qrsize).css('height', qrsize)
                          .css('left', p.left-qrsize/2+20).css('top', p.top-qrsize-10)
                          .qrcode(options);
  };
  $(window).resize(function(){
    $('.hoverqrcode').hide();
  });
  $('.article-share-qrcode').click(function(){
    updatehoverqrcode();
    $('.hoverqrcode').toggle();
  });
  $('.article-share-qrcode').hover(function(){}, function(){
      $('.hoverqrcode').hide();
  });
});   
</script>











<link rel="stylesheet" href="/fancybox/jquery.fancybox.css" media="screen" type="text/css">
<script src="/fancybox/jquery.fancybox.pack.js"></script>
<script type="text/javascript">
$(document).ready(function(){ 
  $('.article-content').each(function(i){
    $(this).find('img').each(function(){
      if ($(this).parent().hasClass('fancybox')) return;
      var alt = this.alt;
      if (alt) $(this).after('<span class="caption">' + alt + '</span>');
      $(this).wrap('<a href="' + this.src + '" title="' + alt + '" class="fancybox"></a>');
    });
    $(this).find('.fancybox').each(function(){
      $(this).attr('rel', 'article' + i);
    });
  });
  if($.fancybox){
    $('.fancybox').fancybox();
  }
}); 
</script>



<!-- Analytics Begin -->





<!-- Analytics End -->

<!-- Totop Begin -->

	<div id="totop">
	<a title="Back to Top"><img src="/img/scrollup.png"/></a>
	</div>
	<script src="/js/totop.js"></script>

<!-- Totop End -->

<!-- MathJax Begin -->
<!-- mathjax config similar to math.stackexchange -->


<!-- MathJax End -->

<!-- Tiny_search Begin -->

<!-- Tiny_search End -->

  </body>
</html>
